package double_pointer;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-12-03
 * Time: 15:38
 */
public class IsPalindrome {
    public static boolean isPalindrome(String s) {
        int left = 0;
        int right = s.length() - 1;
        boolean ans = true;
        while (left < right) {
            char l = s.charAt(left);
            char r = s.charAt(right);
            if (!Character.isLetterOrDigit(l)) {
                left++;
                continue;
            }
            if (!Character.isLetterOrDigit(r)) {
                right--;
                continue;
            }
            if (Character.isLetter(l)) {
                l = Character.toLowerCase(l);
            }
            if (Character.isLetter(r)) {
                r = Character.toLowerCase(r);
            }
            if (l != r) {
                ans = false;
                break;
            }
            right--;
            left++;
        }
        return ans;
    }

    public static void main(String[] args) {
        isPalindrome("0P");
    }
}
